<?php
/**
 * test case for WakTool class
 * @author J.Ducastel <nospam0@ducastel.name>
 */
class testWakTool extends UnitTestCase {

    function setUp() {
        $this->kit='webappkit.core';
        $this->name='core';
        $this->cfg=array(
            'key'=>'value');
    }

    function testFactory() {
        $kit_id='webappkit.testkit';
        $cfg=array(
            'key'=>'value');
        $tool=MockupWakTool::toolFactory($kit_id,$cfg);
        $this->assertIsA($tool,'wakTool');
        $this->assertEqual($tool->getKitId(),$kit_id);

        // testing config overriding
        $full_cfg = array(
            'key' => 'value'
            ,'oneToFour'=>array(1,2,3,4));

        $result_cfg = $tool->getCfg();
        $this->assertIsA($result_cfg, 'array'
            , 'getCfg() should return an array');
        $this->assertEqual($tool->getCfg(),$full_cfg
            ,'actual config should be merge result ');
    }
}

class MockupWakTool extends WakTool {

    function toolFactory($kit_id, $cfg) {
        return new MockupWakTool($kit_id, $cfg);
    }

    var $cfg=array(
        'key'=>'default'
        ,'oneToFour'=>array(1,2,3,4));
}
